function RuleStatistic() {
    var baseUrl = "/m/rule/statistics";

    this.get = function (taskId, callback) {
        var data = {};
        data.taskId = taskId;

        $.ajax({
            url: baseUrl,
            data: data,
            success: function (ret) {
                var ruleStatistic = JSON.parse(ret);
                if (ruleStatistic != null) {
                    ruleStatistic.getTotalCount = getTotalCount;
                }
                callback(ruleStatistic);
            }
        });
    }

    /**
     * 从最新结果中统计
     * @param taskId
     * @param callback
     */
    this.getFromTaskResult = function (taskId, callback) {
        var data = {};
        data.taskId = taskId;

        $.ajax({
            url: baseUrl + "/task_result",
            data: data,
            cache: false,
            success: function (ret) {
                var ruleStatistic = JSON.parse(ret);
                if (ruleStatistic != null) {
                    ruleStatistic.getTotalCount = getTotalCount;
                }
                callback(ruleStatistic);
            }
        });
    }

    function getTotalCount() {
        var ruleStatistics = this;
        var totalCount = ruleStatistics.requiredTotalCount +
            ruleStatistics.veryImportantTotalCount +
            ruleStatistics.importantTotalCount +
            ruleStatistics.normalTotalCount;
        return totalCount;
    }
}